/**
 * 
 */
package com.magnusart.scrumppm.presenters;

import java.util.Observer;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

import com.magnusart.scrumify.dao.CommonDAO;

/**
 * @author Magnus Andersson
 *
 */
public abstract class AbstractPresenter<T extends Composite, J extends CommonDAO<?, ?, ?>> implements Listener, Observer
{

	final T view;
	final J dao;
	
	public AbstractPresenter( T view, J dao ) {
		this.view = view;
		this.dao = dao;
	}
	
	/**
	 * Type of widget event that is sent to the listener.
	 * @author Magnus Andersson
	 *
	 */
	public enum WidgetTypes {
		CreateNewButton,
		OpenProjectButton, 
		SelectProjectInList, 
		DeleteProjectButton,
		DetailsAreaSelection, 
		ProjectNameSelection, 
		ProjectSearch;
	}
	
	/**
	 * This method should be called from the constructor
	 * in an implemented method.
	 */
	@SuppressWarnings("unused")
	private void initAll() {
		addListeners();
		initView();
	}
	
	/* (non-Javadoc)
	 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
	 */
	@Override
	public abstract void handleEvent( Event e );

	abstract void addListeners();
	abstract void initView();
}
